<template>
  <el-menu
      :default-active="this.$store.state.menus.editableTabsValue"
      class="el-menu-vertical-demo"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b"
  >
    <router-link to="/index">
      <el-menu-item index="Index" @click="addTab({
            title: '首页',
            name: 'Index',
       })">
        <template slot="title">
          <i class="el-icon-s-home"></i>
          <span slot="title">首页</span>
        </template>
      </el-menu-item>
    </router-link>
    <el-submenu :index="menu.name" v-for="menu in menuList">
      <template slot="title">
        <i :class="menu.icon"></i>
        <span>&nbsp;&nbsp;&nbsp;{{menu.title}}&nbsp;&nbsp;&nbsp;</span>
      </template>
      <router-link :to="item.path" v-for="item in menu.children">
        <el-menu-item :index="item.name" @click="addTab(item)">
            <template slot="title">
              <i :class="item.icon"></i>
              <span slot="title">{{item.title}}</span>
            </template>
        </el-menu-item>
      </router-link>
    </el-submenu>
  </el-menu>
</template>

<script>
import store from "@/store";

export default {
  name: "SideMenu",
  data(){
    return{
    }
  },
  computed:{
    menuList:{
      get(){
        return this.$store.state.menus.menuList;
      }
    }
  },
  methods:{
    addTab(item){
      this.$store.commit("add" +
          "" +
          "" +
          "Tab",item)
    }
  }
}
</script>

<style>
.el-menu-vertical-demo {
  height: 100%;
}

.el-aside {
  background-color: #D3DCE6;
  color: #333;
  text-align: center;
  line-height: 200px;
}
</style>